#include <iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
    string s;
    getline(cin,s);

    reverse(s.begin(),s.end());
    int n=s.size();
    int l=0;
    while(l<n){
        int r=l;
        while(r<n&&s[r]!=' ') r++;
        reverse(s.begin()+l, s.begin()+r);
        while (r<n&&s[r]==' ') {
            r++;
        }
        l=r;
    }
    cout<<s<<endl;
    return 0;
}